<!DOCTYPE html>
<head>
    <title>

    </title>
    @include('web.layout.head')
    <link rel="stylesheet" href="{{asset('/css/web/product/product.css')}}">
    <link rel="stylesheet" href="{{asset('/css/web/inc/public_goods_details.css')}}">
    <script src="{{asset('/js/web/product/scroole.min.js')}}"></script>
    <script src="{{asset('/js/web/product/jquery.SuperSlide.2.1.1.js')}}"></script>
    <script src="{{asset('/js/web/product/imgshow.js')}}"></script>
    <script src="{{asset('/js/web/product/share.js')}}"></script>
    <script src="{{asset('/js/web/product/jquery.jqzoom.js')}}"></script>
    <style>
        .page a {
            border: none !important;
            padding: 0 !important;
        }
    </style>
    <script type="text/javascript">
    var province_name = "<?php echo !empty($province_name)?$province_name:""; ?>";
    var city_name = "<?php echo !empty($city_name)?$city_name:""; ?>";
        $(function () {
            // 商品数量选择脚本
            var buy_limit = 0;
            var buy_num_msg = '超出库存！';
            // 商品为促销商品则设置购买数量限制为1
            $("#add-btn").click(function () {
                var n = parseInt($("#num-inp").val());//购物件数
                var s = buy_limit == 0 ? parseInt($("#inven-num").html()) : buy_limit;
                $price = $(".word_price").html();
                if(!$price){
               	 $price = $(".priceinfo").html();
                }
                if (n >= s) {
                    $("#num-inp").val(s);
                    $('.in_num').html(s +'件');
                    //$.MsgBox.Alert("温馨提示", buy_num_msg);
                    $('.in_price').html('￥' + (new Number($price.replace("￥","")*s).toFixed(2))+'元');
                } else {
                    $("#num-inp").val(n + 1);
                    $('.in_num').html(n + 1 +'件');
                    $('.in_price').html('￥' + (new Number($price.replace("￥","")*(n+1)).toFixed(2))+'元');
                }
            })
            $("#cut-btn").click(function () {
                var n = parseInt($("#num-inp").val());
                var s = buy_limit == 0 ? parseInt($("#inven-num").html()) : buy_limit;
                if (s > 0) {
                	  $price = $(".word_price").html();
                      if(!$price){
                     	 $price = $(".priceinfo").html();
                      }
                    if (n > 1) {
                        $("#num-inp").val(n - 1);
                        $('.in_num').html(n - 1 +'件');
                        $('.in_price').html('￥' + (new Number($price.replace("￥","")*(n - 1)).toFixed(2))+'元');
                    } else {
                        $("#num-inp").val(1);
                        $('.in_num').html(1 +'件');
                        $('.in_price').html('￥' + (new Number($price.replace("￥","")*1).toFixed(2))+'元');
                    }
                } else {
                	 $price = $(".word_price").html();
                     if(!$price){
                    	 $price = $(".priceinfo").html();
                     }
                    if (n > 0) {
                        $("#num-inp").val(n - 1);
                        $('.in_num').html(n - 1 +'件');
                        $('.in_price').html('￥' + (new Number($price.replace("￥","")*(n - 1)).toFixed(2))+'元');
                    } else {
                        $("#num-inp").val(0);
                        $('.in_num').html(0 +'件');
                        $('.in_price').html('￥' + (new Number($price.replace("￥","")*0).toFixed(2))+'元');
                    }
                }
             })
            $("#num-inp").keyup(function () {
                var n = parseInt($("#num-inp").val());
                var s = buy_limit == 0 ? parseInt($("#inven-num").html()) : buy_limit;
                if (n > s) {
                    alert(buy_num_msg)
                    //$.MsgBox.Alert("温馨提示", buy_num_msg);
                    $("#num-inp").val(s);
                    $('.in_num').html(s +'件');
                    return false;
                } else {
                	 $price = $(".word_price").html();
                     if(!$price){
                    	 $price = $(".priceinfo").html();
                     }
                    if (s > 0) {
                        if (n > 1) {
                            $("#num-inp").val(n);

                            $('.in_num').html(n +'件');
                            $('.in_price').html('￥' + (new Number($price.replace("￥","")*n).toFixed(2))+'元');
                        } else {
                            $("#num-inp").val(1);
                            $('.in_num').html(1 +'件');
                            $('.in_price').html('￥' + (new Number($price.replace("￥","")*1).toFixed(2))+'元');
                        }
                    } else {
                        if (n > 0) {
                            $("#num-inp").val(n);
                            $('.in_num').html(n +'件');
                            $('.in_price').html('￥' + (new Number($price.replace("￥","")*n).toFixed(2))+'元');
                        } else {
                            $("#num-inp").val(0);
                            $('.in_num').html(0 +'件');
                            $('.in_price').html('￥' + (new Number($price.replace("￥","")*0).toFixed(2))+'元');
                        }
                    }
                }
                _freight();//运费
            });
        })
    </script>

</head>

<body class="por body-info">
@include('web.layout.product_head')
<!-- 文件上传配置 -->

<div class="w1200 pro-info">
    <div class="crumbs">
        <a href="/shop/index/{{$product['shop_id']}}" class="home">首页</a>　>　
        <a href="{{asset('/product/search')}}">所有商品</a>　>　
        <a href="{{asset('/product/product_list/')}}/{{$c1_id}}">{{$c1}}</a>　>　
        <a href="{{asset('/product/product_list/')}}/{{$c2_id}}">{{$c2}}</a>　>
        {{$c3}}</div>
    <div class="w-f f-cb fir-wrap">
        <div class="fl pro-img">
            <div class="imgbig jqzoom">
                <img src="{{asset('/img/web/icon/loading.gif')}}">
                <!-- <img id="probig" jqimg="{{$product['cover_image']}}" width="350" height="350" src="" > -->
            </div>
            <div class="imglist">
                <div class="list">
                    <ul>
                    <?php
                    $imgs =json_decode($product['images'],true);
                    if(is_array($imgs)){
                        foreach($imgs as $img){
                    ?>
                        <li class="active"><img data-img="{{$img}}" alt="{{$product['name']}}" src="{{$img}}" data-big="{{$img}}"></li>
                       <?php
                    }
                    }
                       ?>
                    </ul>
                </div>
            </div>
            <div class="bot-box bdsharebuttonbox f-cb bdshare-button-style0-16" data-bd-bind="@if(isset($sku['sku_code'])){{$sku['sku_code']}}@endif">
                <span class="ser fl">商品编号：<span id="sku_code">@if(isset($sku['sku_code'])){{$sku['sku_code']}}@endif</span></span>
                <br/>
                <a href="javascript:;" class=" more bds_more" data-cmd="more">分享</a>
                <a href="javascript:;" id="atten" class="atten">@if(array_get($check,'checkGoods'))已关注@else 关注@endif</a>
                @if(array_get($check,'checkShop')&&session('user_id')!=null)
                    <a href="javascript:;" id="star" class="star ">已收藏店铺</a>
                @else
                    <a href="javascript:;" id="star" class="star collection_shop">收藏店铺</a>
                @endif
            </div>
        </div>
        <div class="cent-wrap fl">
            <h3>{{$product['product_desc']}}</h3>
            <h1 hidden>{{$product['product_desc']}}</h1>

            <div class="pro-price f-cb">
                <div id="ajax_price" class="fl left" style="position: relative">
                    <div class="original_price"><span>原价</span><font class="priceinfo s-pri">￥@if(isset($sku['price'])){{$sku['price']}}@endif</font></div>
                    <div class="price"><span>促销价</span><font class="s-priceinfo pri fl sales">￥@if(isset($sku['sale_price'])){{$sku['sale_price']}}@endif</font></div>
                </div>
                <div class="fr trade-num">
                    <p>交易成功</p>
                    <p class="num">{{$product['succ_num']}}</p>
                </div>
                <div class="fr eva-num">
                    <p>累积评价</p>
                    <p class="num">{{$product['comment_count']}}</p>
                </div>

            </div>
            <div class="tips f-cb">
              <!--  <div class="delivery fl"><span class="send">配送：</span><span class="start">浙江省杭州</span><i
                            class="end">至</i> @include('web.layout.freightcity')</div> --> 
                <div class="cost fl">运费：<span class="money">@if(isset($sku['freight']) && $sku['freight']) {{$sku['freight']}} @else 包邮 @endif</span><span class="freight_hint"></span></div>
            </div>
            <div class="standard" id="attribute">

            @if(is_array($attrs))
            @foreach($attrs as $ak=> $attr)
                <div class="row f-cb field">
                    <span class="fl stt" data-id="19">{{$attr}} ：</span>
                    @if(isset($attrs_value[$ak]))
                    <div class="fl list-lab">
                    @foreach($attrs_value[$ak] as $vk=> $val)

                        <span data-name="{{$ak}}:{{$vk}}" class="click sx{{$ak}}-{{$vk}}">{{$val}}</span> <!--hover-->

                    @endforeach
                    </div>
            		@endif
                </div>
            @endforeach
            @endif
                <input type="hidden" name="skus" id="skus" value="{{$skus}}">
                {{--<input type="hidden" name="_token" value="koJIMjHttHtIa1XXCKj7F5JZbGBdctnecwaBnRpg">--}}
                <input type="hidden" name="_token" value="{{csrf_token()}}">
                {{ csrf_field() }}
            </div>
            <div class="num-msg f-cb">
                <span class="fl numc">采购数量：</span>
                <div class="numbox fl f-cb">
                    <a href="javascript:;" class="jian fl" id="cut-btn">-</a>
                    <input name="num" id="num-inp" class="fl num" type="text" value="1">
                    <a href="javascript:;" class="jia fl" id="add-btn">+</a>
                </div>
                <span class="fl inven">
                    (库存<span id="inven-num" data-promotion-num="{{isset($sku['stock'])? $sku['stock'] : 0}}">{{isset($sku['stock'])? $sku['stock'] : 0}}</span>件)
                    </span>
            </div>
            <?php if(isset($sku['stock']) && $sku['stock'] > 0){?>
            <div class="shop-btn f-cb purchase">
                <a href="javascript:void 0;" company-id="<?php echo isset($info['user_id']['company_id'])?$info['user_id']['company_id']:1; ?>" class="add-car fl">加入进货单</a>
                <a href="javascript:;" class="buy fl">立即购买</a>
            </div>
            <?php }else{?>
            <div class="shop-btn f-cb halt"  >
                <span style="font-size: 18px;color:gray;">该商品已售罄！</span>
            </div>
            <?php }?>
            @if (count($errors) > 0)
                <div class="shop-btn f-cb halt"  >
                    @foreach ($errors->all() as $error)
                        <span style="font-size: 18px;color:gray;">{{ $error }}</span>
                    @endforeach
                </div>

            @endif
        </div>


         <div class="new-right-brand fr">
            <span class="img"><img src="@if(isset($shop['sp_logo'])) {{$shop['sp_logo']}} @endif" alt=""></span>
            <h2>@if(isset($shop['sp_name'])) {{$shop['sp_name']}} @endif</h2>
            <div class="txt">店铺等级：
            <?php

                    if(isset($shop['shop_level']['lv_ico_tag'])){

                for($i =0;$i<$shop['shop_level']['lv_ico_tag'];$i++){
            ?>
                <img src="{{asset('/img/web/product/grade_img01.png')}}">
            <?php
                 }
            }
            ?>
            </div>
            <div class="txt">经营模式：@if(isset($shop['company_material']['business_model'])) {{$shop['company_material']['business_model']}} @endif</div>
            <div class="txt">所在地区：@if(isset($shop['company']['reg_location'])) {{$shop['company']['reg_location']}} @endif</div>
              <div class="txt">联系商家：
                  @if(isset($shop['user']['name']))
                      <a href="javascript:void(0);" data-id="{{session('user_id')}}" id="contact">
                         点击联系<img src="{{asset('img/contactus.gif')}}">
                      </a>
                  @endif</div>
            <div class="xian"></div>
            <div class="quality text-left">
                <span>描述</span>
                <font class="red">@if(isset($shop['product_comment_score']) && $shop['product_comment_count'] > 0) {{sprintf(".2f%",$shop['product_comment_score'] / $shop['product_comment_count']) }} @else 4.9 @endif↓</font>
            </div>
            <div class="quality text-center">
                <span>服务</span>
                <font class="red">@if(isset($shop['seller_comment_score']) && $shop['seller_comment_count'] > 0) {{sprintf(".2f%",$shop['seller_comment_score'] / $shop['seller_comment_count']) }} @else 4.9 @endif -</font>
            </div>
            <div class="quality  text-right">
                <span>物流</span>
                <font class="green">@if(isset($shop['logistics_comment_score']) && $shop['logistics_comment_count'] > 0) {{sprintf(".2f%",$shop['logistics_comment_score'] / $shop['logistics_comment_count']) }} @else 4.9 @endif↑</font>
            </div>
            <a class="fl btn_store" href="/shop/index/{{$product['shop_id']}}">进入店铺</a>

             @if(array_get($check,'checkShop')&&session('user_id')!=null)
                 <a class="fr collect_store star">已收藏店铺</a>
             @else
                 <a class="fr collect_store collection_shop star">收藏店铺</a>
             @endif
        </div>
    </div>
    <div class="pro-info-wrap f-cb w-f">
        <div class="fl left-wrap">
            <div class="text_left">
                <h4>猜你喜欢</h4>
            </div>
            <div class="main-box left-hotlist">

                <ul>
                @if(is_array($related_product))
                @foreach($related_product as $rp)
                @if(isset($rp['skus'][0]))
                                                                        <li>

                                <a href="{{asset('/product/info')}}/{{$rp['id']}}/@if(isset($rp['skus'][0])){{$rp['skus'][0]['id']}} @else 0 @endif" class="img bigbox"><img src="{{$rp['cover_image']}}" alt=""></a>
                                <div class=" cont">
                                    <span class="pri">￥@if(isset($rp['skus'][0])){{$rp['skus'][0]['price']}} @else 0.00 @endif</span>
                                    <a href="{{asset('/product/info')}}/{{$rp['id']}}/@if(isset($rp['skus'][0])){{$rp['skus'][0]['id']}} @else 0 @endif" class="name">{{$rp['name']}}</a>
                                </div>
                            </li>
                             @endif     
				@endforeach
                  @endif                  </ul>
            </div>
        </div>
        <div class="fr right-wrap">
            <div class="top-wrap">
                <div id="infonav" class="navbox f-cb">
                    <ul class="fl">
                        <li class="hover"><a href="#goodsdetail">商品详情</a></li>
                        <li><a href="#userspingj">用户评价<span class="oran">({{$product['comment_count']}})</span></a>
                        </li>
                    </ul>
                </div>
                <div class="p-parameter f-cb">
                    <ul>
                     <li><span>产品名称：</span>{{$product['name']}}</li>
                        <li><span>商品品牌：</span>{{$brnad}}</li>
                        <li title="{{$product['model']}}"><span>商品型号：</span>{{$product['model']}} </li>
                        <li title="{{$product['name']}}"><span>产品类型： </span>{{$c3}}</li>
                        <li><span>质保年限： </span> @if(is_numeric($product['guarantee_period'])) {{$product['guarantee_period']}}年 @else {{$product['guarantee_period']}} @endif</li>
                        <li><span>商品产地：</span>{{$product['place_origin']}}</li>
                        <?php if($product['custom_attrs']){
                            $attrs = explode(";",$product['custom_attrs']);
                            $arrs = [];
                            foreach($attrs as $attr){
                                $at = explode(",",$attr);
                                
                                $t1 = "";
                                $t2 = "";
                                if(isset($at[0])){
                                    $tmp = explode(":",$at[0]);
                                    if(isset($tmp[1])){
                                        $t1 = $tmp[1];
                                    }
                                }
                             
                                   
                                if(isset($at[1])){
                                    $tmp = explode(":",$at[1]);
                                    if(isset($tmp[1])){
                                        $t2 = $tmp[1];
                                    }
                                }
                                
                                $arrs[$t1][] = $t2;
                                
                         
                            }
                       
                            if($arrs){
                                foreach($arrs as $k=> $a){
                                    $s = implode(",",$a);
                                    ?>
                                        <li><span>{{$k}}：</span>{{$s}}</li>
                                        <?php 
                                }
                            }
                        }
                       
                        ?>
						
                    </ul>
                </div>
            </div>
            <div class="cent-info-main">
                <div class="boxs img-intr" id="goodsdetail" style="padding-top: 40px; display: block;">
                {!!$product['product_detail']!!}
                </div>


                <div class="boxs evalu-wrap" id="userspingj" style="padding-top: 40px;">
                    <div class="top-graded f-cb">
                        <div class="fl left-grade">
                            <span class="big-gra fl"><i>5.0</i>分</span>
                            <div class="fl sche">
                                <div class="sch-box">
                                    <ul>
                                        <li>非常不满意</li>
                                        <li>不满意</li>
                                        <li>一般</li>
                                        <li>满意</li>
                                        <li>非常满意</li>
                                    </ul>
                                    <span class="s-sch01" style="right: 0%;" id="aquare"><span id="totalfen">5.0</span><span>分</span></span>
                                </div>
                                <p>共<span class="red">{{$product['comment_count']}}</span>位购买者参与评分</p>
                            </div>
                        </div>
                    </div>

                    <div class="evalu-list">
                        <div class="top-screen f-cb">
                            <label class="lab fl">
                                <input checked="" value="0" name="type" class="fl rad typesec" type="radio">
                                <span class="fl">全部</span>
                            </label>
                            <label class="lab fl">
                                <input value="1" name="type" class="fl rad typesec" type="radio">
                                <span class="fl">好评<span class="s-num"></span></span>
                            </label>
                            <label class="lab fl">
                                <input value="2" name="type" class="fl rad typesec" type="radio">
                                <span class="fl">中评<span class="s-num"></span></span>
                            </label>
                            <label class="lab fl">
                                <input value="3" name="type" class="fl rad typesec" type="radio">
                                <span class="fl">差评<span class="s-num"></span></span>
                            </label>
                        </div>
                        <div id="comment_list" class="list">
                        </div>

                    </div>
                </div>

            </div>

            <div class="pledge">
                <ul>
                    <li class="li-fir">
                        <h4>正品行货</h4>
                        <p>e井在线服务平台向您保证所售商品均为正品行货，可联系商家开具发票。</p>
                    </li>
                    <li class="li-sec">
                        <h4>全国联保</h4>
                        <p>可凭借质保证书及发票在全国就近售后维修网点享受维修或升级服务。</p>
                    </li>
                </ul>
            </div>
            <div class="state-copy">
                <b class="tt">权利声明：</b>
                <p>e井在线服务平台上的所有商品信息、客户评价、商品咨询、网友讨论等内容，是e井在线服务平台重要的经营资源，未经许可，禁止非法转载使用。</p>
                <p><span class="bold">注：</span>e井在线服务平台为第三方交易平台及信息服务提供者，所展示的商品/服务的标题、价格、详情等信息内容系由店铺经营者发布，其真实性、准确性和合法性均由店铺经营者负责，用户在购买商品/服务前注意谨慎核实。如用户对商品/服务的标题、价格、详情等任何信息有任何疑问的，请在购买前与店铺经营者沟通确认；如用户发现店铺内有任何违法/侵权信息，请立即向平台举报并提供有效线索。感谢您的理解与支持！</p>
            </div>

        </div>
    </div>
</div>


<div class="alert-prompt">
    <div class="titbox f-cb">
        <span class="fl tt">提示</span>
        <span class="fr close"></span>
    </div>
    <div class="contwrap w-f">
        <div class="centbox">
            <div class="success f-cb">
                <span class="ico fl"></span>
                <div class="fl">
                    <p class="f20">您已成功收藏该店铺！</p>
                    <a target="_blank" href="{{asset('/member/buyer/collection?type=2')}}">查看我的收藏></a>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="bg-alert"></div>
<!-- login-content -->
<!-- <form action="/register/login" method="post" accept-charset="utf-8" class="form-horizontal"
      onsubmit="javascript:return false;" id="frm-post-login" name="frm-post">
    <div style="display:none">
        <input type="hidden" name="_scfs" value="f233ff8638c6109bc19e4c2658432c94"/>
    </div>
    <div class="info-obox ol popup" style="display: none">
        <div class="hd"><a href="javascript:;" id="mb_close" class="close fr"></a>您尚未登录</div>
        <div class="login-wrap box">
            <div class="titbox f-cb">
                <h3 class="fl">账户登录</h3>
                <a href="/login/register" class="fr">免费注册</a>
            </div>
            <div class="inp-box user">
                <input name='uname' class="tex" id="uname" type="text" placeholder="输入用户名/手机号码">
            </div>
            <div class="inp-box pass">
                <input name='pwd' class="tex" type="password" placeholder="输入用户密码">
            </div>
            <div class="bot-link f-cb">
                <a href="/login/forget " class="fr">忘记密码？</a>
            </div>
            <input class="sub-btn" type="submit" value="登　　录">
        </div>
    </div>
</form> -->
<div class="info-obox hl popup tianjia" style="display: none">
    <div class="hd"><a href="javascript:;" id="mb_close" class="close fr"></a></div>
    <div class="content">
        <div class="tips">添加商品成功！</div>
        <div class="btns f-cb">
            <a href="javascript:location.reload();" class="fl continue">继续购物</a>
            <a href="{{asset('/member/buyer/carts')}} " class="fr">去结算</a>
        </div>
    </div>

</div>
<div class="mask2"></div>
<form action="{{asset('/order/submit_cart')}}" method="post" accept-charset="utf-8" id="form-post" name="form-post">
    {{csrf_field()}}
    <input name="sku_id" id="sku_id" type="hidden"  value="@if(isset($sku['id'])){{$sku['id']}}@endif">
    <input name="sku_id" id="product_id" type="hidden"  value="{{$product['id']}}">
    <input type="hidden" name="product_type" value="direct_cart"/>
    <input name="num" id="num" type="text" hidden>
</form>

@include('web.layout.footer_ware1')
<script src="{{asset('/control/msgbox/jquery.msgbox.js')}}"></script>
<script>
    @if(time() < 12111)
    var distance_time = $('.product_activity_box').data('time-interval');

    function GetRTime_zk() {
        distance_time -= 1;
        var d = 0;
        var h = 0;
        var m = 0;
        var s = 0;
        if (distance_time >= 0) {
            d = Math.floor(distance_time / 60 / 60 / 24);
            h = Math.floor(distance_time / 60 / 60 % 24);
            m = Math.floor(distance_time / 60 % 60);
            s = Math.floor(distance_time % 60);
        }
        document.getElementById("t_d_zk").innerHTML = d + "天";
        document.getElementById("t_h_zk").innerHTML = h + "时";
        document.getElementById("t_m_zk").innerHTML = m + "分";
        document.getElementById("t_s_zk").innerHTML = s + "秒";
    }

    setInterval("GetRTime_zk()", 1000);
    @endif

    $(function () {

        //规格参数处理
        var attrcontent = JSON.parse($("#skus").val());
        var sku_id = $('#sku_id').val();
        var attributes = [];
        var attr_content;
        $.each(attrcontent, function (index, ele) {
            if(attrcontent[index].id == sku_id){
                attr_content = attrcontent[index];
                attributes = attrcontent[index].attributes;
                attributes = attributes.split(';');
            }
        })

        $.each(attributes, function (index, ele) {
            if($('.standard span').hasClass('click')){
                $('.standard span.sx' + ele.split(',')[0].split(':')[0] + '-' + ele.split(',')[1].split(':')[0]).addClass("hover");
            }
        })
        $('.pro-price .s-pri').html('￥' + (new Number(attr_content.price).toFixed(2)));
        $('.pro-price .pri').html('￥' + (new Number(attr_content.sale_price).toFixed(2)));
        if($('#inven-num').data('promotion-num') < attr_content.stock  && $('#inven-num').data('promotion-num') != 0){
            $('#inven-num').html($('#inven-num').data('promotion-num'));
        }else{
            $('#inven-num').html(attr_content.stock);
        }
        $('input[name="attribute"]').val(attr_content.id);
        $('#sku_code').html(attr_content.sku_code);
        if (attr_content.stock <= 0) {
            $(".halt").show();
            $(".purchase").hide();
        }

        function montage() {
            var val = "";
            $(".pro-info .cent-wrap .standard .row").each(function () {

                for (attr in attrcontent) {

                    var sku_id = $('#sku_id').val();
                    $.each(attrcontent[attr].attributes.split(';'), function (index, ele) {
                        $('.standard span.sx' + ele.split(',')[0].split(':')[0] + '-' + ele.split(',')[1].split(':')[0]).addClass("hover");
                    })
                    $('.pro-price .s-pri').html('￥' + (new Number(attrcontent[attr].price).toFixed(2)));
                    $('.pro-price .pri').html('￥' + (new Number(attrcontent[attr].sale_price).toFixed(2)));
                    if ($('#inven-num').data('promotion-num') < attrcontent[attr].stock && $('#inven-num').data('promotion-num') != 0) {
                        $('#inven-num').html($('#inven-num').data('promotion-num'));
                    } else {
                        $('#inven-num').html(attrcontent[attr].stock);
                    }
                    $('input[name="attribute"]').val(attrcontent[attr].id);
                    $('#sku_code').html(attrcontent[attr].sku_code);
                    if (attrcontent[attr].stoc <= 0) {
                        $(".halt").show();
                        $(".purchase").hide();
                    }
                }
            })
        }
        function montage() {
            var val = "";
            $(".pro-info .cent-wrap .standard .row").each(function () {

                if ($(this).children('.list-lab').children('span').hasClass('hover')) {
                    val += $(this).children('.list-lab').children('span.hover').data("name") + ",";
                } else {
                    val += '0-0' + ",";
                }

            });
            console.log('val',val)
            return val;
        }

        function checkNature(vget) {

            var arrvalue = $.grep(vget.split(","), function (n) {
                return $.trim(n).length > 0;
            });

            var attjson = [];


            $.each(attrcontent, function (index, ele) {
                var vavue = '';

                $.each(attrcontent[index].attributes.split(';'), function (index2, ele2) {
                    vavue += ele2.split(',')[0].split(':')[0]+ ':' + ele2.split(',')[1].split(':')[0] + ',';
                })
                //console.log('vavue',vavue)
                //console.log('vget',vget)
                if (vget == vavue) {
                    attjson = [{
                        "sale_price": attrcontent[index].sale_price,
                        "price": attrcontent[index].price,
                        "id": attrcontent[index].id,
                        "stock": attrcontent[index].stock,
                        "sku_code": attrcontent[index].sku_code,
                    }];

                    return false;
                }

            })
            return attjson;
        }

        $('.standard').delegate('.click', 'click', function () {
            if (!$(this).hasClass('hover')) {
                $(this).addClass('hover').siblings('span').removeClass('hover');
            } else {
                $(this).removeClass('hover');
            }
            var data_name = $(this).attr('data-name');
            var natureGroup = montage();
            var checkNull = checkNature(natureGroup);
            //console.log(checkNull);
            if (checkNull != '') {
                location.href = '/product/info/' + '{{$product['id']}}' + '/' + checkNull[0]['id'];
            } else {
                $('.pro-price .s-pri').html('￥' + 0 + '.00');
                $('.pro-price .pri').html('￥' + 0 + '.00');
                $('#inven-num').html(0);
                $('input[name="attribute"]').val(0);
                $('#sku_code').html('');
                $('.in_price').html('￥' + 0 + '.00');
            }


            var html = '';
            $('.click').each(function (index, el) {
                if ($(this).hasClass('hover')) {
                    html = html + '<font>' + $(this).text() + '</font>';
                }
            });
            $('.skues').html(html);

            var innum = $('#inven-num').html() * 1;
            if (innum < 1) {
                $(".halt").show();
                $(".purchase").hide();
            } else {
                $(".halt").hide();
                $(".purchase").show();
            }


        })





        //查看用户是否登入，判断是否跳转到购买页面
        $(".buy").click(function () {
            var sku_id = '@if(isset($sku['id'])){{$sku['id']}}@endif';
            var num = $("[name='num']").val();

            location.href = '/member/buyer/orders/create?type=direct&sku_id=' + sku_id + '&sku_num=' + num;
        });

        //关注商品
        $("#atten").click(function () {
            if (jud == '' || jud == '0') {
                layer.confirm('请先登录后再关注商品，点击【确认】跳转到登录页面', {
                    title: '温馨提示',
                    btn: ['确认', '取消'] //可以无限个按钮
                }, function (index) {
                   window.location.href = AJAX_URL + '/user/login';
                }, function (index, layero) {
                    layer.close(index);
                });
                return false;

            } else {
                if ($(this).html().indexOf('已关注')>=0){
                    layer.alert('您已成功关注该商品');
                }else {
                    var pid = '{{$product["id"]}}';
                    var sku_id = '@if(isset($sku['id'])){{$sku['id']}}@endif';
                    var shop_id = '{{$product["shop_id"]}}';
//                    var pid = 9378;
                    var token = $('input[name="_token"]').val();
                    $.ajax({
                        url: '/product/collection',
                        type: 'GET',
                        dataType: 'json',
                        data: {'product_id': pid, '_token': token, 'type': 'product', 'sku_id': sku_id, 'shop_id': shop_id},
                        success: function (data) {
                            if (data.code == 0) {
                                layer.alert('已成功关注该商品');
                                $('.atten').html('已关注');
                            } else {
                                layer.alert('商品关注失败');
                            }
                        }

                    })
                }
            }
        });
        //关注商品结束

        //收藏店铺
        $(".collection_shop").click(function () {
            if (jud == '' || jud == '0') {
                layer.confirm('请先登录后再关注商铺，点击【确认】跳转到登录页面', {
                    title: '温馨提示',
                    btn: ['确认', '取消'] //可以无限个按钮
                }, function (index) {
                   window.location.href = AJAX_URL + '/user/login';
                }, function (index, layero) {
                    layer.close(index);
                });
                return false;

            } else {
                var pid = '{{$product["id"]}}';
                var shop_id = '{{$product["shop_id"]}}';
//                    var pid = 9378;
                var token = $('input[name="_token"]').val();
                $.ajax({
                    url: '/product/collection',
                    type: 'GET',
                    dataType: 'json',
                    data: {product_id: pid, _token: token,type:'shop','shop_id':shop_id},
                    success: function (data) {
                        if (data.code == 0) {
                            $('#frm-post input,textarea').removeClass('error');
                            $(".alert-prompt,.bg-alert").show();
                            $('.star').html('已收藏店铺');
                        }else{
                            layer.alert('店铺收藏失败');
                        }
                    }

                })
            }

        });// 收藏店铺结束

        $(".pro-price .eva-num").click(function () {
            $("body,html").stop().animate({scrollTop: $("#infonav").offset().top - 20}, 300);
            $(" .right-wrap .navbox li").eq(1).click();
        });


})


</script>
<script>
    imgShow($(".pro-img .list"), $(".pro-img .imgbig"), 5, 65, "margin-left");
    $(function () {

        $(".cent-info-main .boxs").eq(0).show();

        setTimeout(function () {
            $(".jqzoom").jqueryzoom({
                xzoom: 350, //放大图的宽度
                yzoom: 350, //放大图的高度
                offset: 10, //离原图的距离
                position: "right", //放大图的定位(默认是 "right")
                preload: 1
            });
        }, 1000);


        $("#recom-pro").slide({mainCell: ".bd > ul", autoPlay: true, effect: "leftLoop", vis: 5, interTime: 4000});

        //导航切换
        $("#infonav li").bind('click', function () {
            var n = $(this).index();
            $(".cent-info-main .boxs").eq(n).show().siblings('.boxs').hide();
            $(this).addClass('hover').siblings('li').removeClass('hover');
        });
        //联系议价员
        $('.yj .contact').click(function (event) {
            $('.i-alert-sec').show();
        });
        //导航固定
        $(window).scroll(function () {
            if ($(window).scrollTop() >= $(".right-wrap .top-wrap").offset().top - 2) {
                $(".right-wrap .navbox").addClass('fixed');
            } else {
                $(".right-wrap .navbox").removeClass('fixed');
            }
        });
        if ($(window).scrollTop() >= $(".right-wrap .top-wrap").offset().top) {
            $(".right-wrap .navbox").addClass('fixed');
        } else {
            $(".right-wrap .navbox").removeClass('fixed');
        }

        //评价加载
        var url1 = "/product/evaluate_ajax/667/0"


        //评价图片放大
        $(".right-wrap").delegate('.pic img', 'click', function () {
            var iid = parseInt($(this).attr('iid')) + 1;
            $(this).attr('iid', iid);
            if (parseInt($(this).attr('iid')) % 2 == 0) {
                $(this).parent().parent().parent().next().show()
            } else {
                $(this).parent().parent().parent().next().hide()
            }
        })


        $(".alert-prompt .close").click(function () {
            $(this).parents(".alert-prompt").hide();
            $(".bg-alert").hide();
        });


    })


    //首次刷新ajax价格变化
    $(function () {
        //var arr=get_ajax_value();
        var ccid = '667'


        //关闭弹窗
        $('.popup .close,.continue').click(function (event) {
            $('.popup').hide();
            $('.mask2').hide();
        });

        //click修改价格
        /*$(".click").click(function () {
            $("[name='attribute']").val(0);
            var arr = {arr: get_ajax_value()};
            var jud = 1;
            $.each(arr['arr'], function (key, value) {
                if (!value) {
                    jud = 0;
                }
            })
            if (jud) {
                $.ajax({
                    url: '/product/price_ajax',
                    data: arr,
                    type: 'get',
                    dataType: 'json'
                })
                    .done(function (data) {
                        if (!data) {
                            jud = 0;
                        }
                        if (jud) {
                            $(".s-pri").html('￥ ' + (new Number(data.price).toFixed(2)));
                            $(".sales").html('￥ ' + (new Number(data.sales).toFixed(2)));
                            if ($('#inven-num').data('promotion-num') < data.stock && $('#inven-num').data('promotion-num') != 0) {
                                $('#inven-num').html($('#inven-num').data('promotion-num'));
                            } else {
                                $('#inven-num').html(data.stock);
                            }
                            $("[name='attribute']").val(data.id);
                        } else {
                            $(".s-pri").html('所选择的属性商品不存在');
                            $(".sales").html('￥');
                            $("#inven-num").html(0);
                            $("[name='attribute']").val(0);
                        }
                    })
            }
        })*/
        //表格颜色
        $('.parameter-wrap table tr').each(function (index, el) {
            var index = $(this).index();
            if (index % 2 == 0) {
                $(this).css('background', '#f7f7f7');
            }
            ;
        });


    })

    //获取当前选中的商品的参数值
    function get_ajax_value() {
        var ccid = '667'
        var ob = $("#attribute .field");
        var arr = {};
        for (var i = 0; i < ob.length; i++) {
            var field = ob.eq(i).find('.stt').data('field');
            var value = ob.eq(i).find('.hover').data('id');
            arr[field] = value;
        }
        arr['ccid'] = ccid;
        return arr;
    }


    //登入
    $('#frm-post-login').on('submit', function (event) {
        url = $(this).attr('action');
        data = $(this).serializeArray();
        $.ajax({
            url: url,
            type: 'POST',
            dataType: 'json',
            data: data
        })
            .done(function (data) {
                var status;
                if (data.status == 0) {
                    $('.validate').remove();
                    $('#frm-post input,div,textarea').removeClass('error');
                    var i = 0;
                    $.each(data.msg, function (putid, putv) {
                        i++;
                        if (i == 1) {
                            put(putv)
                        }
                        $('#' + putid).removeClass('success').addClass('error');
                    });
                } else if (data.status == 1) {
                    window.location.reload();
                }
                ;


            })
    });
</script>

<script type="text/javascript">

    //加载评论
    $(document).ready(function () {
        var params = {page: 1, type: ''};
        var url = '/product/comments/{{$product["id"]}}';
        $.get(url, params, function (res) {
            $('#comment_list').html(res);
        }, 'text');
        $(document.body).on('click', '#comment_list .pagination a', function () {
            var url = $(this).attr('href');
            if (url && url != '#') {
                $.get(url, function (res) {
                    $('#comment_list').html(res);
                }, 'text');
            }
            return false;
        });
        $('input[name=type]').change(function () {
            var params = {page: 1, type: $(this).val()};
            var url = '/product/comments/{{$product["id"]}}';
            $.get(url, params, function (res) {
                $('#comment_list').html(res);
            }, 'text');
        });
    });
</script>
<script type="text/javascript">
    $(function () {
        //判断分数
        var fen = parseInt($("#totalfen").text());
        if (fen > 0 && fen <= 1) {
            $("#aquare").css("left", "32px");

        } else if (fen > 1 && fen <= 2) {
            $("#aquare").css("left", "120px");

        } else if (fen > 2 && fen <= 3) {
            $("#aquare").css("left", "210px");

        } else if (fen > 3 && fen <= 4) {
            $("#aquare").css("left", "302px");

        } else {
            $("#aquare").css("left", "390px");

        }

		var page =  1;
        $(".btn_batch").click(function(){
        	 $.ajax({
                 url: AJAX_URL + '/product/related',
                 type: 'GET',
                 dataType: 'html',
                 data: {brand_id:"11",page:++page},
                 success: function (data) {
                     if(data){
                    	 $(".related_list").html(data);
                     }else{
                         page = 1;
                     }

                 }
             })
        });
    });


    // 加入进货单
    var jud = '{{ Session::get("user_id")}}';
//    alert(jud);
    var checkIm = '{{isset($shopImCheck)?$shopImCheck:false}}';

    $(".add-car").click(function () {
        var pid = '{{$product["id"]}}';
        var num = $("#num-inp").val();
        var attribute = "@if(isset($sku['id'])){{$sku['id']}}@endif";
        var company_id = '{{$product["shop_id"]}}';
        if (attribute == 0) {
            layer.alert('商品属性不正确，请重新选择');
            return false;
        }
        //存入数据库
//        if(jud){
            $.ajax({
                url: "{{url('/member/buyer/carts/')}}",
                type: 'post',
                dataType: 'json',
                data: {
                    product_id: pid,
                    num: num,
                    shop_id: company_id,
                    sku_id: attribute,
                },
                success: function (data) {
                    if (data.code == 0) {
                        $(".tianjia,.mask2").show();
                    }else{
                        layer.alert(data.message);
                    }
                }
            });
//        }
    });


    //关闭弹窗
    $('.popup .close,.continue').click(function (event) {
        $('.popup').hide();
        $('.mask2').hide();
    });


</script>

</body>
</html>